<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label required">商品分类编号</label>
        <div class="layui-input-block">
            <input type="text" name="goodscategoryid" lay-verify="required" lay-reqtext="用户名不能为空" placeholder="请输入用户名" value="" class="layui-input">
            <tip>填写自己管理账号的名称。</tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">商品分类名称</label>
        <div class="layui-input-block">
            <input type="text" name="goodscategoryname" placeholder="商品分类名称" value="" class="layui-input">
            <input type="hidden" name="cname" placeholder="创建人" value="admin" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
    </div>
    <!--<div class="layui-form-item">
        <div class="layui-input-block">
            <button type="button" id="test1" lay-filter="test1" class="layui-btn layui-btn-normal"></button>
            <button type="button" id="test2" lay-filter="test2" class="layui-btn layui-btn-danger"></button>
            <button type="button" id="test3" lay-filter="test3" class="layui-btn layui-btn-warm"></button>
            &lt;!&ndash;<input class="layui-btn layui-btn-warm" id="btnClose" type="button" value="关闭本页" onClick="custom_close()" />&ndash;&gt;
        </div>
    </div>-->

</div>
<script src="../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="../../js/YouJs/config.js"></script>
<script src="../../js/YouJs/reqInterceptor.js"></script>
<script>
    layui.use(['form','upload'], function () {
        var form = layui.form,
            layer = layui.layer,
            upload = layui.upload,
            $ = layui.$;
        $.ajaxSetup({
            // 发送cookie
            xhrFields: {
                withCredentials: true
            },
            // 请求发送前
            beforeSend: function () {
                // 发送请求前，可以对data、url等处理
            },
            // 请求返回
            complete: function () {
                // 返回数据，根据数据调转页面等
            }
        });
        //监听提交
        form.on('submit(saveBtn)', function (data) {

            $.ajax({
                url: config.gatewayUri+'/good/api/goods-category/admin/saveOrUpdateGoodsCategory',
                dataType: 'json',
                data: data.field,
                xhrFields: {withCredentials: true},
                type: 'post',
                success: function (res) {
                    var index = layer.alert(JSON.stringify(res), {
                        title: '最终的提交信息'
                        //layer.alert(data.field.goodscategoryname+"23123")
                    }, function () {
                        // 关闭弹出层
                        layer.close(index);

                        var iframeIndex = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(iframeIndex);
                    });
                }
            })
            return false;
        });
    })
</script>
</body>
</html>